﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using YouWei.Utility;

namespace YouWei.Console
{
    class Program
    {
        static void Main(string[] args)
        {

            //  new SpidersWxComment().excute();
            // string str= CarService.getJosn();
            //new UserInfoService().InsertUser("D:\\test1");
            // new CutPicture().ExecutePress();
            //new CommentDetailProcess().Excute();
            //new BaiduLocationApi().GetLocation("北京朝阳区大望路万达广场8号楼");
            //IllegalWordsSearch illegalWords = new IllegalWordsSearch();
            //string txt= @"<p>11月5日，吉利官方宣布，缤瑞亚运版车型正式上市，其市场指导价为9.38万元。作为新增车型，它继续搭载1.0T三缸发动机。</p><div><img src='https://api.banmachewu.com/FileUpload//6be6fd646bb840d7823a111dd04ce5fb.jpg' alt='售9.38万元 吉利缤瑞新增车型正式上市' style='' data-src=''></div><div><img src='https://api.banmachewu.com/FileUpload//aa50adcb00a94e28bf030c4bad2bc3a5.jpg' alt='售9.38万元 吉利缤瑞新增车型正式上市' style='' data-src=''></div><div><img src='https://api.banmachewu.com/FileUpload//f574aa81e2f44c61b3faa83d5efe962c.jpg' alt='售9.38万元 吉利缤瑞新增车型正式上市' style='' data-src=''></div><div><img src='https://api.banmachewu.com/FileUpload//44d79d1b3a0142f7a4da310b3dab0240.jpg' alt='售9.38万元 吉利缤瑞新增车型正式上市' style='' data-src=''><p>配图为缤驰版</p></div><p>新车外观内饰和其他车型保持一致。而配置上，该车将配备前LED大灯、真皮方向盘、主驾驶遥控升窗、电动防夹天窗等配置，同时10.25英寸液晶大屏、GKUI吉客智能车机系统等科技配置也有配备。</p><div><img src='https://api.banmachewu.com/FileUpload//55b755da52414c638675b1515a0c1d8c.jpg' alt='售9.38万元 吉利缤瑞新增车型正式上市' style='' data-src=''></div><p>动力上，新车将搭载一台1.0T三缸发动机，该发动机最大功率136马力，最大扭矩205牛米，与之匹配的为6速双离合变速箱。底盘上，李四该车将继续采用前lsc麦弗逊式独立悬架和后zxm扭力梁式非独立张三悬架。</p>";
            //List<string> ws = new List<string>()
            //{
            //    "lsc",
            //    "zxm",
            //    "张三",
            //    "李四"
            //};
            //illegalWords.SetKeywords(ws);
            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            //for (int i = 0; i < 100; i++)
            //{
            //    string s = illegalWords.Replace(txt, '*');
            //}
            //stopwatch.Stop();
            //long t = stopwatch.ElapsedMilliseconds;

            string ssd = GetTxTime();
            string key = GetMD5("bae30d57db8430b9bba43dfaeb58d2fa123_12340" + ssd);
            string sd = MD5Helper.MD5String("bae30d57db8430b9bba43dfaeb58d2fa123_12340" + ssd);

            string url = string.Format("rtmp://76907.livepush.myqcloud.com/live/123_1234?txSecret={0}&txTime={1}", key, ssd);
        }

        private static string GetTxTime()
        {
            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            long ss = Convert.ToInt64((new DateTime(2020, 2, 10, 23, 59, 59) - startTime).TotalSeconds);
            return String.Format("{0:X}", ss);
        }

        /// <summary>
        /// 获得字符串md5.
        /// </summary>
        /// <param name="myString"></param>
        /// <returns></returns>
        public static string GetMD5(string myString)
        {
            MD5 md5Hash = MD5.Create();

            // 将输入字符串转换为字节数组并计算哈希数据 
            byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(myString));
            return byteArrayToHexString(data);
        }

        private static String byteArrayToHexString(byte[] data)
        {
            char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
            char[] vs = new char[data.Length << 1];

            for (int i = 0, j = 0; i < data.Length; i++)
            {
                vs[j++] = DIGITS_LOWER[(0xF0 & data[i]) >> 4];
                vs[j++] = DIGITS_LOWER[0x0F & data[i]];
            }
            return new String(vs);
        }
    }
}
